import Vue from "vue";
import Router from "vue-router";

import home from "@/components/Home";
import article from "@/components/Article";
import topic from "@/components/Topic";
import topic_article from "@/components/TopicArticle";
import bonus from "@/components/Bonus";
import login from "@/components/Login";
import download from "@/components/Download";

Vue.use(Router);

const router = new Router({
  routes: [
    {
      path: "/",
      component: home,
      children: [
        {
          path: "/",
          name: "Home",
          component: article
        }
      ]
    },
    {
      path: "/topic",
      component: topic,
      children: [
        {
          path: "/",
          name: "Topic",
          component: topic_article
        }
      ]
    },
    {
      path: "/bonus",
      name: "bonus",
      component: bonus
    },
    {
      path: "/login",
      name: "login",
      component: login
    },
    {
      path: "/download",
      name: "download",
      component: download
    },
    {
      path: "*",
      name: "error",
      redirect: { name: "Home" }
    }
  ]
});
router.beforeEach((to, from, next) => {
  next();
});
export default router;
